package com.dotflat.satistics.vo.home;

import com.dotflat.satistics.utils.MathUtil;
import lombok.Data;

/**
 * *******************************
 * Created by Tim.
 * form com.matt
 * on 2018/7/25
 * *******************************
 */
@Data
public class AreaIncomeRateVo {
    private String areaName;
    private double planAmount;
    private double actualAmount;
    private double rate;

    public static AreaIncomeRateVo of(String areaName, double actualAmount, double planAmount){
        AreaIncomeRateVo vo = new AreaIncomeRateVo();
        vo.setAreaName(areaName);
        vo.setPlanAmount(planAmount);
        vo.setActualAmount(actualAmount);
        if (planAmount < 0){
            vo.setRate(-1);
        }else {
            vo.setRate(MathUtil.divide(vo.getActualAmount(), vo.getPlanAmount()));
        }
        return vo;
    }
}
